package saas.dev.clouduserprovide.listener;

/**
 * @author : y1
 * @className : TestListener
 * @date: 2022/7/20 13:49
 * @description :
 */

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import saas.dev.clouduserprovide.event.OrderEvent;
import saas.dev.clouduserprovide.event.TestEvent;

@Slf4j
@Component
public class TestListener {
    // 修改状态 01 235
    @SneakyThrows
    @EventListener(TestEvent.class)
    public void test(TestEvent event) {
        Object source = event.getSource();
        String orderId = event.getOrderId();

        long start = System.currentTimeMillis();
        Thread.sleep(2000);
        long end = System.currentTimeMillis();
        log.info("TestEvent:{}-{}：测试事件：({})毫秒", source, orderId, (end - start));
    }

    @SneakyThrows
    @EventListener(OrderEvent.class)
    public void test1(OrderEvent event) {
        Object source = event.getSource();
        String orderId = event.getOrderId();
        long start = System.currentTimeMillis();
        Thread.sleep(2000);
        long end = System.currentTimeMillis();
        log.info("OrderEvent:{}-{}：测试事件：({})毫秒", source, orderId, (end - start));
    }
}
